package cn.cj.erp.bo.system;

import cn.cj.erp.common.SearchParam;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.ArrayList;
import java.util.List;

/**
 * 用户与角色对应关系
 *
 * @author chenjian
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class SysUserRoleBo extends SearchParam {
    /** 用户ID */
    private Long userId;

    /** 角色ID */
    private Long roleId;

    public static SysUserRoleBo newInstance(Long userId, Long roleId) {
        SysUserRoleBo bo = new SysUserRoleBo();
        bo.setUserId(userId);
        bo.setRoleId(roleId);
        return bo;
    }

    public static List<SysUserRoleBo> newList(Long userId, List<Long> roleIds) {
        List<SysUserRoleBo> list = new ArrayList<>();
        for (Long roleId : roleIds) {
            SysUserRoleBo bo = new SysUserRoleBo();
            bo.setUserId(userId);
            bo.setRoleId(roleId);
            list.add(bo);
        }
        return list;
    }
}
